package com.tzq.SERVLET;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;

import com.tzq.JAVABEAN.ConnectDB;

/**
 * Servlet implementation class CreateAlbumServlet
 */
public class CreateAlbumServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public CreateAlbumServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		PrintWriter out = response.getWriter();
		String SQLParam[] = new String[3];
		String albumname=request.getParameter("AlbumName");
	    String albumdescription =request.getParameter("AlbumDescription");
	    String userid = request.getSession().getAttribute("pid").toString();
	    SQLParam[0] = albumname;
	    SQLParam[1] = userid;
	    SQLParam[2] = albumdescription;
	    String sql  ="insert into ImageAlbum values(?,?,?,0)";
	    int[] WhichInt = {0,1,0};
	    ConnectDB conn = new ConnectDB();
		boolean myBean = conn.updatesql(sql,SQLParam,3,WhichInt);
		if(myBean==false){
			out.print("create failed");
		}else{
			//response.sendRedirect("Log_in.jsp");
			out.print("create success");
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request,response);
	}

}
